package com.bidevalution.business.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bidevalution.business.service.BeMethodDefineService;
import com.bidevalution.business.service.BeMethodStepService;
import com.bidevalution.business.service.BeParameterReferenceService;
import com.bidevalution.dao.entity.BeMethodDefine;
import com.bidevalution.dao.entity.BeMethodStep;
import com.bidevalution.dao.extend.BeMethodDefineExt;
import com.bidevalution.dao.mapper.BeMethodDefineMapper;
import com.qtp.core.util.IdsUtil;

@Service
public class BeMethodDefineServiceImpl implements BeMethodDefineService {

	@Autowired
	private BeMethodDefineMapper beMethodDefineMapper;
	@Autowired
	private BeMethodStepService beMethodStepService;
	@Autowired
	private BeParameterReferenceService beParameterReferenceService;

	@Transactional
	public void insert(BeMethodDefine beMethodDefine) {
		beMethodDefine.setSeqId(IdsUtil.uuid());
		beMethodDefineMapper.insert(beMethodDefine);
		BeMethodStep beMethodStep = new BeMethodStep();
		beMethodStep.setCreateTime(new Date());
		beMethodStep.setDefineId(beMethodDefine.getSeqId());
		beMethodStep.setOrderNum(1);
		beMethodStep.setParentId("0");
		beMethodStep.setSeqId(IdsUtil.uuid());
		beMethodStep.setStepCode("1");
		beMethodStep.setStepName("专家承诺");
		beMethodStep.setUpdateTime(new Date());
		beMethodStepService.insert(beMethodStep);
		beMethodStep = new BeMethodStep();
		beMethodStep.setCreateTime(new Date());
		beMethodStep.setDefineId(beMethodDefine.getSeqId());
		beMethodStep.setOrderNum(2);
		beMethodStep.setParentId("0");
		beMethodStep.setSeqId(IdsUtil.uuid());
		beMethodStep.setStepCode("2");
		beMethodStep.setStepName("推选组长");
		beMethodStep.setUpdateTime(new Date());
		beMethodStepService.insert(beMethodStep);

	}

	@Override
	public void update(BeMethodDefine beMethodDefine) {
		beMethodDefineMapper.updateByPrimaryKey(beMethodDefine);
	}

	@Override
	public BeMethodDefine selectByPrimaryKey(String seqId) {
		return beMethodDefineMapper.selectByPrimaryKey(seqId);
	}

	@Override
	public List<BeMethodDefineExt> selectForList() {
		return beMethodDefineMapper.selectForList();
	}

	@Override
	public void deleteById(String seqId) {
		beMethodDefineMapper.deleteByPrimaryKey(seqId);
	}

	@Override
	public BeMethodDefine selectByCode(String code,String area) {
		return beMethodDefineMapper.selectByCode(code,area);
	}
}
